<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('设置平台进度')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <div th:each="platform, platformIndex : ${progressInfos}">
            <input id="platformId[[${platformIndex.index}]]" name="platformId" th:field="*{platform}" type="hidden" th:value="${platform.platformId}">
            <!-- 渲染平台信息 -->
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">平台名称：</label>
                <div class="col-sm-8">
                    <input id="platformName[[${platformIndex.index}]]" name="platformName" th:field="*{platform.platformName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">当前进度：</label>
                <div class="col-sm-8">
                    <select id="currentProgress[[${platformIndex.index}]]" name="currentProgress" th:field="*{platform.currentProgress}" class="form-control" required>
                        <option value="0">未处理</option>
                        <option value="1">资料核对（待处理）</option>
                        <option value="2">提交资料（已介入）</option>
                        <option value="3">等待回电（处理中）</option>
                        <option value="4">回电确认（处理完毕）</option>
                        <option value="5">已生效（结案）</option>
                    </select>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />

    <script type="text/javascript">
	    var prefix = ctx + "system/customer";
        $('#currentProgress').change(function () {
            var platformId = $(this).closest('.form-group').find('input[name="platformId"]').val();
            var currentProgress = $(this).closest('.form-group').find('select[name="currentProgress"]').val();

            // 当前进度为0时，弹窗提示
            var confirmChange = confirm("是否要改变当前平台为" + $('#currentProgress option:selected').text() + "状态？");
            // 用户点击确认
            if (confirmChange) {
                var jsonStr = {
                    "customerId":$("#customerId").val(),
                    "platformId":platformId,
                    "currentProgress":currentProgress,
                };
                var data = JSON.stringify(jsonStr);
                $.ajax({
                    async: false,
                    cache: false,
                    url: ctx + '/system/customer/addProgress',
                    method: 'POST',
                    data: data,
                    dataType: "json",
                    contentType : "application/json",//发送信息至服务器时内容编码类型
                    success: function (data) {
                        if(data!=null && data.code ==0){
                            $.modal.alert("设置成功");
                        }
                    },
                    error: function () {
                        $.modal.alert("设置失败");
                    }
                });
            } else {
                // 用户点击取消，可以进行相应的操作或不做处理
            }
        });
    </script>
</body>
</html>
